package com.lylg.picture_share.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lylg.picture_share.dao.ManagerMapper;
import com.lylg.picture_share.entity.Manager;
import com.lylg.picture_share.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ManagerServiceImpl implements ManagerService {
    @Autowired
    private ManagerMapper managerMapper;
    @Override
    public Manager selectManagerByNP(String manager_name, String manager_pwd) {
        return managerMapper.selectManagerByNP(manager_name,manager_pwd);
    }

    @Override
    public List<Manager> selectManagers(Manager manager) {
        return managerMapper.selectManagers(manager);
    }
    @Override
    public void updPwd(Integer managerId, String manager_pwd) {
        managerMapper.updatePwd( managerId,  manager_pwd);
    }

    @Override
    public void updateStatus(Integer manager_id) {
        managerMapper.updStatus(manager_id);
    }

    @Override
    public void saveManager(Manager manager) {
        managerMapper.saveManager(manager);
    }

    @Override
    public List<Manager> selectAllManagers(Manager manager) {
        return managerMapper.selectAllManagers(manager);
    }

    @Override
    public PageInfo<Manager> getManagers(Manager manager, Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Manager> managers = managerMapper.selectManagers(manager);
        PageInfo<Manager> managerPageInfo = new PageInfo<>(managers);
        return managerPageInfo;
    }
}
